package com.fub.util.database.databaseHelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class NodesDatabaseManager extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "nodes.db";
	private static final int Version = 3;
	public static final String TABLE_NAME_NODES = "nodes";
	public static final String COL_TYPE = "type";
	public static final String COL_ROOMLABEL = "room_label";
	public static final String COL_ID = "_id";
	public static final String COL_BUILDING_ID = "building_id";
	public static final String COL_X = "x";
	public static final String COL_Y = "y";
	public static final String COL_Z = "z";
	private static final String CREATE_TABLE_NODES = String
			.format("create table %s ( %s  text not null , %s text not null, %s text not null, %s integer not null, %s integer not null, %s integer not null, %s text not null);",
					TABLE_NAME_NODES, COL_ID, COL_BUILDING_ID, COL_TYPE, COL_X, COL_Y,
					COL_Z, COL_ROOMLABEL);

	public NodesDatabaseManager(Context context) {
		super(context, DATABASE_NAME, null, Version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_TABLE_NODES);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_NODES);
		onCreate(db);
	}

}
